
import ModelMesh from "@/editor/domain/model/ModelMesh";
import KY3D from "@/editor/KY3D";
import MeshHelper from "../helper/MeshHelper";

export default class MeshMgr implements IMgr {

    startUp(): void {
        console.log('mesh mgr start up')
    }

    dispose(): void {

    }

    getModelMeshByType(type: number, data: any, uuid?: string, color?: any): ModelMesh {

        return MeshHelper['update' + type](data, uuid, color);
    }

    addModelMesh(meshs:any[]):void {

        for(let mesh of meshs){
            KY3D.MGR.scene.main.scene.add(mesh);
        }
    }

    getMeshFormId(uuid: string) {

        let childs = KY3D.MGR.scene.main.scene.children;
        for(let child of childs){
            if(child.uuid === uuid) {
                return child;
            }
        }
    }

    removeModelMesh(uuid:string) {
        let childs = KY3D.MGR.scene.main.scene.children;
        for(let child of childs){
            if(child.uuid === uuid) {
                KY3D.MGR.scene.main.scene.remove(child);
            }
        }
    }
}